package com.yty.myadmin.controler;

import com.yty.myadmin.dao.SysUserDAO;
import com.yty.myadmin.domain.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class Index {

    @Autowired
    private SysUserDAO sysUserDAO;

    @RequestMapping("/index")
    String getIndex(HttpServletRequest request, Model model){
        SecurityContextImpl securityContext = (SecurityContextImpl)
                request.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
        String name = securityContext.getAuthentication().getName();
//        System.out.println("!!!!!!11"+securityContextImpl.getAuthentication().getName());
        model.addAttribute("name",name);
        return "index";
    }
}
